<?php
namespace Shakeadmin\Controller;
use Think\Controller;
class IndexController extends ExtendController {
	public function index(){
		$CFG = M("ShopCfg");
		$cfg = current($CFG->where(Array("sid"=>$this->sid))->limit(1)->getField("id,start_time,end_time,tms_newcomer,tms_everyday"));

		$this->assign("cfg",$cfg);
		$this->display();
	}
	public function gamecfg_save(){
		$cfgid = I("cfgid");
		$start_time = I("start_time");
		$end_time = I("end_time");
		$tms_newcomer = I("tms_newcomer");
		$tms_everyday = I("tms_everyday");
		
		$data["start_time"]=$start_time;
		$data["end_time"]=$end_time;
		$data["tms_newcomer"]=$tms_newcomer;
		$data["tms_everyday"]=$tms_everyday;

		$CFG = M("ShopCfg");
		if($cfgid){
			$CFG->where(Array("id"=>$cfgid,"sid"=>$this->sid))->save($data);
		}else{
			$data["sid"]=$this->sid;
			$data["sessionkey"]=$this->top_session;
			$data["refresh_token"]=$this->refresh_token;
			$data["usernick"]=$this->usernick;
			$data["jointime"]=date("Y-m-d H:i:s",time());
			$data["taobao_user_id"]=$this->taobao_user_id;
			// $data["taobao_user_id"]=0;
			$data["logintime"]=date("Y-m-d H:i:s",time());
			$CFG->add($data);
		}
		
		$this->success("保存成功！");
	}
}